package com.example.zx.keysoapapplication;

import android.os.Bundle;

import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private ListView lv;
   private List<Food> foods=new ArrayList<Food>();
    public void init(){
        int [] kk=new int[]{R.drawable.get,R.drawable.ll};

        for(int i=0;i<kk.length;i++){
            Food food=new Food();
            food.setTitle("Title ..." + i);
            food.setContext("Context..." + i);
            food.setPic(kk[i]);
            foods.add(food);
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
        setContentView(R.layout.activity_main);
        lv=(ListView)findViewById(R.id.lv);
        MyAdapter adapter=new MyAdapter(foods,getLayoutInflater());
                lv.setAdapter(adapter);


        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                TextView tv=(TextView)view;
                Log.i("zx",tv.getText().toString());
            }
        });
    }
    public void getResponse(View view){

    }


}
